home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-10-25 | 5.9 KB | 241 lines | [TEXT/ttxt] |
- \ Utility words for Yerk
- \ 10/13/84 CBD Combined with Dump.scr
- \ 12/16/84 CBD Made into a module
- \ 1/04/85 cdn Moved in objList
- \ 7/10/86 cdn Moved in .classes
- \ 9/02/86 cdn Added Option & Shift key features to WORDS
- \ 9/04/86 ghs Added pat
- \ 12/04/87 rfl modified .cline to use better format and increased clist size
- \ 12/04/87 rfl fixed dump format
- \ 10/02/90 rfl .pause now in nucleus
- \ 10/26/91 rfl added class hierarchy
- \ 12/14/91 rfl modified .class to not be reentrant..runs out of stack
- \ 12/17/91 rfl improved hier...someday will have browser
- \ 10/16/92 rfl added listing of objects in .clist
- Decimal
-
- :Module Util
-
- : Dump
- base >R HEX CR CR
- ." Dump from address: " over . CR 7 SPACES
- 16 0 DO I 3 .R LOOP 2 SPACES
- 16 0 DO I 0 <# # #> TYPE LOOP CR
- OVER + SWAP DUP 15 AND XOR
- DO CR i 0 6 D.R SPACE
- i 16 + i 2DUP
- DO ic@ SPACE 0 <# # # #> TYPE LOOP
- 2 SPACES
- DO ic@ DUP 32 < OVER 126 > OR
- IF DROP 46 THEN
- EMIT
- LOOP
- ?pause
- 16 +LOOP
- CR R> -> BASE ;
-
- \ pull name from stream and dump from its NFA
- : .W @Pfa nfa 100 Dump ;
-
- \ List words in dictionary
- : Words { \ eop wbase -- }
- latest true
- mods: fEvent 2048 and \ option key is down- prompt for word name
- IF 2drop " List from name:" doInDlg dup
- IF drop sFind 0= Abort" not found"
- drop nfa true
- THEN
- THEN
- mods: fEvent 512 and \ shift key is down- prompt for address
- IF 2drop " List from hex address:" doInDlg dup
- IF drop here >str255 1+ here c@ >uc
- BL here count + c! \ make usable by "number"
- base -> wbase hex
- here number drop 0 max latest
- BEGIN 2dup pfa lfa @ < \ find the nearest word
- WHILE pfa lfa @
- REPEAT swap drop true
- wbase -> base
- THEN
- THEN
- 0= IF exit THEN \ Cancel button from a dialog box
- getvrect: fWind drop 15 - 6 / 20 / 20 * 21 - -> eop 2drop
- Base -> wbase HEX Cr Cr 0 -> out
- BEGIN
- dup dup 6 .R
- dup 1+ C@
- IF space ID.
- ELSE ." Null" drop
- THEN out eop >
- IF Cr 0 -> Out
- ELSE 20 out over mod - spaces
- THEN pfa lfa @ dup 0=
- ?Pause
- UNTIL
- drop Cr wbase -> Base ;
-
- \ trav handler for finding objects of a class
- : ofind { theCfa theClass -- }
- theCfa @ theClass =
- IF cr theCfa >name dup id. .h THEN ;
-
- : objList { addr len \ theClass -- } addr len sFind
- 0= ?error 122
- drop ?isClass 0= ?error 122 -> theClass
- cr ." Objects of class: " addr len type
- 'c ofind theClass trav cr ;
-
- 0 value cList
- 0 value level
- 0 value #obs
-
- hex \ changes text in place
- Create >lc ( addr len -- addr len )
- 2e17 w, \ move.l (sp),d7
- 206f0004 , \ move.l 4(sp),a0
- d1cb w, \ adda.l a3,a0
- 5387 w, \ subq #1,d7
- 1018 w, \ lp move.b (a0)+,d0
- 0c000041 , \ cmpi.b #65,d0
- 6b0e w, \ bmi.s out
- 0c00005a , \ cmpi.b #90,d0
- 6e08 w, \ bgt.s out
- d03c0020 , \ add.b #32,d0
- 1140ffff , \ move.b d0,-1(a0)
- 51cfffe8 , \ out dbra d7,lp
- next,
- decimal
-
- \ trav handler for finding objects of a class
- : obfind { theCfa theClass \ len -- }
- theCfa @ theClass =
- IF cr level 1+ 2* spaces theCfa >name dup .h 2 spaces n>count -> len
- here len cmove here len >lc type \ move name to here
- 1 ++> #obs
- THEN ;
-
- ' meta constant lastCl
-
- \ Handler to add all classes to cList during a Trav
- : addClass { theCfa parm -- }
- theCfa lastCl >
- IF theCfa 4+ ?IsClass
- IF add: cList
- ELSE drop
- THEN
- THEN ;
-
- : fillClist clear: clist 0 add: clist 'c addClass 0 trav ;
-
- \ ( ind -- ^super )
- : superOF at: cList sfa @ ;
-
- \ find the next subclass for the given superclass ptr
- : nextSub { ^sup start \ bool -- subInd t OR f }
- 0 -> bool
- size: cList start
- DO i superOF ^sup =
- IF i true -> bool Leave
- THEN
- LOOP bool ;
-
- : tab 6 * @xy drop - 6 / spaces ;
-
- \ print a line of data for this class
- : .cline ( ind -- )
- cr level 2* spaces
- at: cList dup dup nfa 4 tface id. 0 tface
- dup dfa w@ 35 tab ." Dlen:" . dfa 2+ w@ 46 tab ." Width:" .
- 'c obfind swap trav ;
-
- \ patch .cline .cline1
-
- \ ( ind -- ind subInd t OR ind f ) try to nest into subclass
- : ?sub dup at: clist 0 nextSub ;
-
- \ ( ind -- newInd t or f ) try to find a peer class
- : ?peer
- dup superOF lastCL =
- IF false THEN
- dup superOF swap 1+ nextSub ;
-
- : findPeer { ind -- ind }
- BEGIN ind ?peer \ does it have a peer class?
- IF -> ind true \ yes, so get out
- ELSE -1 ++> level level 0= \ no, so pop up and do again
- IF 0 -> ind true
- ELSE -> ind false
- THEN
- THEN
- UNTIL ind ;
-
- : classTrav { ind -- }
- BEGIN ?terminal
- IF (key) drop cr .pause (key)
- cr 0 -> out 32 > IF exit THEN
- THEN
- ind .cline
- ind ?sub \ does it have a subclass?
- IF 1 ++> level -> ind \ yes, so dip down and save last class index
- ELSE findPeer -> ind \ otherwise find next peer
- THEN
- ind not
- UNTIL ;
-
- : .cl size: clist 0 DO i at: clist cr nfa id. LOOP ;
-
- : .classes 0 -> level 0 -> #obs
- 400 heap> Ordered-Col -> cList
- fillClist size: clist 1- classTrav level 0 do drop loop cr cr
- size: clist ." number of classes is " . cr
- #obs ." number of objects is " . cr
- dispose> cList ;
-
- rect pbox
-
- \ Display the system pen patterns
- : pat { \ pattern -- }
- 0 -> pattern -curs cls
- 1 8 50 38 put: pbox 6 0
- DO 7 0
- DO pattern 38 = IF 3 sysPat +base call PenPat THEN
- 55 0 offset: pbox pattern sysPat fill: pbox draw: pbox
- getBotX: pbox 38 - getBotY: pbox 9 + gotoxy pattern .
- 1 ++> pattern
- LOOP
- -385 40 offset: pbox
- LOOP
- 0 sysPat +base call PenPat
- CR +curs
- ;
-
-
- \ ************
- \ : (chain) { myobj \ tab -- } cr 0 -> tab
- \ BEGIN 2 ++> tab myObj sfa @ -> myObj
- \ myObj nfa n>count 2dup tab spaces type cr " OBJECT" s=
- \ UNTIL ;
-
- : (chain) { myObj \ tab -- } 40 heap> ordered-col -> clist
- cr 0 -> tab myObj add: clist
- BEGIN myObj sfa @ -> myObj
- myObj add: clist
- myObj nfa n>count " OBJECT" s=
- UNTIL
- size: clist 0
- DO 2 ++> tab last: clist nfa n>count tab spaces type cr
- size: clist 1- remove: clist
- LOOP dispose> clist ;
-
- : hc'
- @word count sfind
- IF drop (chain) THEN ;
-
- : hier " List class hierarchy of class:" doInDlg
- IF sFind 0= Abort" not found"
- drop ?isclass IF (chain) ELSE abort" not a class" THEN
- THEN ;
-
-
- ;Module
-